package com.pandai.leetcode;

public class Solution203 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode fake = new ListNode(0);
        fake.next = head;
        ListNode prev = fake;
        ListNode cur = head;
        while(cur!=null){
            if(cur.val == val){
                prev.next = cur.next;
            }else{
                prev = prev.next;
            }
            cur = cur.next;
        }
        return fake.next;
    }
}
